home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Review 28
/
Creative-Review-CD-ROM-28.iso
/
pc
/
kungfu
/
assets
/
game.dir
/
00003_Script_cell manager class
< prev
next >
Wrap
Text File
|
1997-08-08
|
8KB
|
325 lines
-- cell manager class
-- --------------------------------------------------
-- for 0.1m
-- can hold more than more actor in each cell
-- --------------------------------------------------
property cellsize
property celllist
property actorwidth
property celloffset
property floor
property offsetlist
-- ==================================================
-- new method
-- --------------------------------------------------
on new me
minit me
return me
end mnew
-- ==================================================
-- minit method
-- --------------------------------------------------
on minit me
set celloffset = 5
set cellsize = 20
set actorwidth = 4
set floor = 280
set offsetlist = data2list ( "offset" )
mclean me
end minit
-- ==================================================
-- mclean method
-- --------------------------------------------------
on mclean me
set celllist = []
repeat with index = 1 to 50
add celllist, []
end repeat
end mclean
-- ==================================================
-- mscreen2cell method
-- --------------------------------------------------
on mscreen2cell me, loc
return (( loc ) / cellsize )
end mscreen2cell
-- ==================================================
-- mcell2screen method
-- --------------------------------------------------
on mcell2screen me, loc
return (loc ) * cellsize
end mcell2screen
-- ==================================================
-- mget method
-- --------------------------------------------------
on mget me, cellnumber
set index = cellnumber + celloffset
return getat ( celllist, index )
end mget
-- ==================================================
-- madd method
-- --------------------------------------------------
on madd me, cellnumber, who
-- put "in mset cell"
set thecell = mget ( me, cellnumber )
add thecell, who
-- put "out mset cell"
end madd
-- ==================================================
-- mdelete method
-- --------------------------------------------------
on mdelete me, cellnumber, who
-- put "in mdelete cell"
set thecell = mget ( me, cellnumber )
deleteone thecell, who
-- put "in mdelete cell"
end mdelete
-- ==================================================
-- mbatchdelete method
-- --------------------------------------------------
on mbatchdelete me, leftcell, who
-- put "in mbatchdelete "
repeat with index = leftcell to leftcell + actorwidth - 1
mdelete me, index, who
end repeat
-- put "out mbatchdelete "
end mbatchdelete
-- ==================================================
-- mdeleteall method
-- --------------------------------------------------
on mdeleteall me, who
-- put "in mdeleteall "
repeat with thecell in celllist
deleteone thecell, who
end repeat
-- put "out mdeleteall "
end mdeleteall
-- ==================================================
-- mbatchadd method
-- --------------------------------------------------
on mbatchadd me, leftcell, who
-- put "ò in mbatchadd cell" leftcell, who
repeat with index = leftcell to leftcell + actorwidth - 1
madd me, index, who
end repeat
-- put "òáout mbatchadd cell"
end mbatchadd
-- ==================================================
-- mbatchadd method
-- --------------------------------------------------
on mjump me, who, oldleftcell, direction
-- put "in mjump cell" oldleftcell, who
mbatchdelete me, oldleftcell, who
case direction of:
#left: set newleftcell = oldleftcell - 8
#right: set newleftcell = oldleftcell + 8
end case
mbatchadd me, newleftcell, who
-- put "out mjump cell"
end mjump
-- ==================================================
-- mstartwalk method
-- --------------------------------------------------
on mstartwalk me, who, oldleftcell, direction
-- put "in mstartwalk cell", who, oldleftcell, direction
case direction of
#right: set cellnumber = oldleftcell + actorwidth
#left:set cellnumber = oldleftcell - 1
end case
madd me, cellnumber, who
-- put "out mstartwalk cell"
end mstartwalk
-- ==================================================
-- mfinishwalk method
-- --------------------------------------------------
on mfinishwalk me, who, oldleftcell, direction
-- put "in mfinishwalk cell", who, oldleftcell, direction
case direction of
#right: set cellnumber = oldleftcell
#left: set cellnumber = oldleftcell + actorwidth - 1
end case
mdelete me, cellnumber, who
-- put "out mfinishwalk cell"
end mfinishwalk
-- ==================================================
-- mbatchcheck method
-- --------------------------------------------------
on mbatchcheck me, leftcell, filterlist
set batchwho = []
if not ( listp ( filterlist )) then set filterlist = []
repeat with index = leftcell to ( leftcell + actorwidth - 1 )
set thiswho = mcheck ( me, index, #none )
repeat with who in thiswho
if not ( getone ( filterlist, who )) and ¼
not ( getone ( batchwho, who )) then add ( batchwho, who )
end repeat
end repeat
return batchwho
end mbatchcheck
-- ==================================================
-- mcheck method
-- --------------------------------------------------
on mcheck me, leftcell, direction
-- put "in mcheck cell " , me, leftcell, direction
case direction of
#none: set newcell = leftcell
#right: set newcell = leftcell + actorwidth
#left: set newcell = leftcell - 1
end case
set who = mget ( me, newcell )
return who
end mcheck me
-- ==================================================
-- mshow method
-- --------------------------------------------------
on mshow me
put "in mshow cell"
put "-----------------------"
repeat with index = 1 to count ( celllist )
put (index - celloffset ), getat ( celllist , index )
end repeat
put "-----------------------"
put "out mshow cell"
end mshow
-- ==================================================
-- mgetstartoffset method
-- --------------------------------------------------
on mgetstartoffset me, direction, data
-- put "in mgetstartoffset cell manager class :"
set list = getaprop ( offsetlist, data )
set startlist = getaprop ( list, #start )
set offset = getaprop ( startlist , direction )
return offset
-- put "out mgetstartoffset cell manager class :"
end mgetstartoffset
-- ==================================================
-- mgetflingoffset method
-- --------------------------------------------------
on mgetflingoffset me, direction, data
-- put "in mgetflingoffset cell manager class :"
set list = getaprop ( offsetlist, data )
set flinglist = getaprop ( list, #fling )
set offset = getaprop ( flinglist , direction )
return offset
-- put "out mgetflingoffset cell manager class :"
end mgetflingoffset
-- ==================================================
-- mgetfloor method
-- --------------------------------------------------
on mgetfloor me
-- put "in mgetfloor cell manager class :"
return floor
-- put "out mgetfloor cell manager class :"
end mgetfloor